package jpa;
import java.util.*;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class Mozdony {

    @Id
    private int id;    
    private int futottkm;
    
    @ManyToOne
    private Tipus type;

    @OneToMany
    private Collection<Vonat> trains;
     
    public Mozdony() {
    }
    
    public Mozdony(int id, int km, Tipus type) {
        this.id = id;
        futottkm = km;
        this.type = type;
        trains = new LinkedList<Vonat>();
    }

    public int getFutottkm() {
        return futottkm;
    }

    public void setFutottkm(int futottkm) {
        this.futottkm = futottkm;
    }

    public int getId() {
    	return id;
    }
    
    public Tipus getTipus() {
        return type;
    }
    
    @Override
    public String toString() {
        return id + " " + type.getAzonosito() + " " + futottkm;
    }
}
